Telegram Group & Telegram Channel
Сегодня я хочу поделиться приёмом, который сильно упростил мне жизнь при отладке в PHP.

🛠️ Как дебажить сложные объекты в Laravel удобно?

Когда ты работаешь с коллекциями, запросами или вложенными структурами, dd() или dump() часто захламляют вывод. Но есть куда более изящный способ:


logger($someObject);


Этот метод не прерывает выполнение скрипта, в отличие от dd(), и пишет в storage/logs/laravel.log. И вот тут начинается магия:

📌 Хочешь, чтобы лог был читаемым? Добавь кастомный формат:


logger()->info('User data', [$user->toArray()]);


Или ещё лучше — используй Laravel-помощники вроде tap():


tap($response, fn($res) => logger($res->toArray()));


💡 Это особенно удобно, когда ты хочешь просто взглянуть на данные, не роняя приложение.


🔥 Бонус: в .env можно задать LOG_LEVEL=debug, и ты увидишь всё, даже что делает сам Laravel под капотом.

Такие мелочи превращают обычную отладку в аккуратный контроль за происходящим в приложении.

А как ты обычно дебажишь в Laravel — через dd() или есть свои фишки?

👉 @php_lib



tg-me.com/php_lib/751
Create:
Last Update:

Сегодня я хочу поделиться приёмом, который сильно упростил мне жизнь при отладке в PHP.

🛠️ Как дебажить сложные объекты в Laravel удобно?

Когда ты работаешь с коллекциями, запросами или вложенными структурами, dd() или dump() часто захламляют вывод. Но есть куда более изящный способ:


logger($someObject);


Этот метод не прерывает выполнение скрипта, в отличие от dd(), и пишет в storage/logs/laravel.log. И вот тут начинается магия:

📌 Хочешь, чтобы лог был читаемым? Добавь кастомный формат:


logger()->info('User data', [$user->toArray()]);


Или ещё лучше — используй Laravel-помощники вроде tap():


tap($response, fn($res) => logger($res->toArray()));


💡 Это особенно удобно, когда ты хочешь просто взглянуть на данные, не роняя приложение.


🔥 Бонус: в .env можно задать LOG_LEVEL=debug, и ты увидишь всё, даже что делает сам Laravel под капотом.

Такие мелочи превращают обычную отладку в аккуратный контроль за происходящим в приложении.

А как ты обычно дебажишь в Laravel — через dd() или есть свои фишки?

👉 @php_lib

BY Библиотека PHP программиста 👨🏼‍💻👩‍💻




Share with your friend now:
tg-me.com/php_lib/751

View MORE
Open in Telegram


Библиотека PHP программиста ‍‍ Telegram | DID YOU KNOW?

Date: |

The lead from Wall Street offers little clarity as the major averages opened lower on Friday and then bounced back and forth across the unchanged line, finally finishing mixed and little changed.The Dow added 33.18 points or 0.10 percent to finish at 34,798.00, while the NASDAQ eased 4.54 points or 0.03 percent to close at 15,047.70 and the S&P 500 rose 6.50 points or 0.15 percent to end at 4,455.48. For the week, the Dow rose 0.6 percent, the NASDAQ added 0.1 percent and the S&P gained 0.5 percent.The lackluster performance on Wall Street came on uncertainty about the outlook for the markets following recent volatility.

How Does Bitcoin Work?

Bitcoin is built on a distributed digital record called a blockchain. As the name implies, blockchain is a linked body of data, made up of units called blocks that contain information about each and every transaction, including date and time, total value, buyer and seller, and a unique identifying code for each exchange. Entries are strung together in chronological order, creating a digital chain of blocks. “Once a block is added to the blockchain, it becomes accessible to anyone who wishes to view it, acting as a public ledger of cryptocurrency transactions,” says Stacey Harris, consultant for Pelicoin, a network of cryptocurrency ATMs. Blockchain is decentralized, which means it’s not controlled by any one organization. “It’s like a Google Doc that anyone can work on,” says Buchi Okoro, CEO and co-founder of African cryptocurrency exchange Quidax. “Nobody owns it, but anyone who has a link can contribute to it. And as different people update it, your copy also gets updated.”

Библиотека PHP программиста ‍‍ from sg


Telegram Библиотека PHP программиста 👨🏼‍💻👩‍💻
FROM USA